package me.firstapp.spi.shop.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import me.firstapp.common.exception.ServiceException;
import me.firstapp.common.exception.StatusHouse;
import me.firstapp.common.json.JsonPage;
import me.firstapp.common.json.ListObject;
import me.firstapp.common.json.PageObject;
import me.firstapp.common.json.SingleObject;
import me.firstapp.common.module.shop.JsonDistributeCall;
import me.firstapp.common.module.shop.JsonOrder;
import me.firstapp.common.module.shop.JsonOrderInManage;
import me.firstapp.common.module.shop.JsonOrderItem;
import me.firstapp.common.module.shop.JsonOrderItemInManage;
import me.firstapp.common.module.shop.JsonPayRecord;
import me.firstapp.spi.base.impl.BaseServiceImpl;
import me.firstapp.spi.shop.OrderService;

@Service
public class OrderServiceImpl extends BaseServiceImpl implements OrderService {

	@Override
	public SingleObject<JsonOrder> createOrder(Long memberId, String remark) {
		SingleObject<JsonOrder> result = new SingleObject<JsonOrder>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("memberId", memberId);
			parameters.put("remark", remark);

			JSONObject resultObject = api(parameters, "/order/createOrder.do", HttpMethod.POST, "创建订单");
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(resultObject.getString("code"))) {
				JSONObject jsonObject = resultObject.getJSONObject("object");
				if (jsonObject != null) {
					JsonOrder order = JSONObject.toJavaObject(jsonObject, JsonOrder.class);
					result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
					result.setObject(order);
				}
			} else {
				throw new ServiceException(resultObject.getString("code"), resultObject.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}
		return result;
	}

	@Override
	public SingleObject<JsonOrder> findOrderByOrderNo(String orderNo, boolean itemsFlag) {
		SingleObject<JsonOrder> result = new SingleObject<JsonOrder>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("orderNo", orderNo);
			parameters.put("itemsFlag", itemsFlag);

			JSONObject resultObject = api(parameters, "/order/findOrderByOrderNo.do", HttpMethod.GET, "根据订单号获取订单");
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(resultObject.getString("code"))) {
				JSONObject jsonObject = resultObject.getJSONObject("object");
				if (jsonObject != null) {
					JsonOrder order = JSONObject.toJavaObject(jsonObject, JsonOrder.class);
					result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
					result.setObject(order);
				}
			} else {
				throw new ServiceException(resultObject.getString("code"), resultObject.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}
		return result;
	}

	@Override
	public SingleObject<JsonOrder> payOrder(Long memberId, String orderNo, String password) {
		SingleObject<JsonOrder> result = new SingleObject<JsonOrder>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("memberId", memberId);
			parameters.put("orderNo", orderNo);
			parameters.put("password", password);

			JSONObject resultObject = api(parameters, "/order/payOrder.do", HttpMethod.POST, "积分支付订单");
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(resultObject.getString("code"))) {
				JSONObject jsonObject = resultObject.getJSONObject("object");
				if (jsonObject != null) {
					JsonOrder order = JSONObject.toJavaObject(jsonObject, JsonOrder.class);
					result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
					result.setObject(order);
				}
			} else {
				throw new ServiceException(resultObject.getString("code"), resultObject.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}
		return result;
	}

	@Override
	public PageObject<JsonOrder> findOrderPage(Integer pageNo, Integer pageSize, Long memberId, Integer status) {
		PageObject<JsonOrder> result = new PageObject<JsonOrder>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("pageNo", pageNo);
			parameters.put("pageSize", pageSize);
			parameters.put("memberId", memberId);
			parameters.put("status", status);

			JSONObject resultObject = api(parameters, "/order/findMemberOrders.do", HttpMethod.GET, "分页查询订单");
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(resultObject.getString("code"))) {
				JSONObject pageJsonObject = resultObject.getJSONObject("page");
				if (pageJsonObject != null) {
					JsonPage<JsonOrder> jsonPage = new JsonPage<>();
					jsonPage.setPageNo(pageJsonObject.getIntValue("pageNo"));
					jsonPage.setPageSize(pageJsonObject.getIntValue("pageSize"));
					jsonPage.setTotalCount(pageJsonObject.getIntValue("totalCount"));
					List<JsonOrder> orderList = new ArrayList<>();
					JSONArray jsonArray = pageJsonObject.getJSONArray("list");
					if (jsonArray != null) {
						for (int i = 0; i < jsonArray.size(); i++) {
							JSONObject _jsonObject = jsonArray.getJSONObject(i);
							if (_jsonObject != null) {
								JsonOrder order = JSONObject.toJavaObject(_jsonObject, JsonOrder.class);
								orderList.add(order);
							}
						}
					}
					jsonPage.setList(orderList);
					result.setPage(jsonPage);
					result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
				}
			} else {
				throw new ServiceException(resultObject.getString("code"), resultObject.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}
		return result;
	}

	@Override
	public SingleObject<JsonOrder> cancelOrder(String orderNo) {
		SingleObject<JsonOrder> result = new SingleObject<JsonOrder>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("orderNo", orderNo);

			JSONObject resultObject = api(parameters, "/order/cancelOrder.do", HttpMethod.POST, "取消订单");
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(resultObject.getString("code"))) {
				JSONObject jsonObject = resultObject.getJSONObject("object");
				if (jsonObject != null) {
					JsonOrder order = JSONObject.toJavaObject(jsonObject, JsonOrder.class);
					result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
					result.setObject(order);
				}
			} else {
				throw new ServiceException(resultObject.getString("code"), resultObject.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}
		return result;
	}

	@Override
	public PageObject<JsonOrderInManage> findOrderPage(Integer pageNo, Integer pageSize,
			Map<String, Object> searchParams, String sortParam, String sortType, Long startTime, Long endTime) {
		PageObject<JsonOrderInManage> result = new PageObject<>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("pageNo", pageNo);
			parameters.put("pageSize", pageSize);
			parameters.put("sortParam", sortParam);
			parameters.put("sortType", sortType);
			parameters.put("startTime", startTime);
			parameters.put("endTime", endTime);
			JSONObject jsonObject = apiBody(parameters, "/order/findOrderPage.do", "分页查询订单", searchParams);
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(jsonObject.getString("code"))) {
				JSONObject pageJsonObject = jsonObject.getJSONObject("page");
				if (pageJsonObject != null) {
					JsonPage<JsonOrderInManage> jsonPage = new JsonPage<>();
					jsonPage.setPageNo(pageJsonObject.getIntValue("pageNo"));
					jsonPage.setPageSize(pageJsonObject.getIntValue("pageSize"));
					jsonPage.setTotalCount(pageJsonObject.getIntValue("totalCount"));
					List<JsonOrderInManage> orderList = new ArrayList<>();
					JSONArray jsonArray = pageJsonObject.getJSONArray("list");
					if (jsonArray != null) {
						for (int i = 0; i < jsonArray.size(); i++) {
							JSONObject _jsonObject = jsonArray.getJSONObject(i);
							if (_jsonObject != null) {
								JsonOrder order = JSONObject.toJavaObject(_jsonObject, JsonOrder.class);
								if (order != null) {
									JsonOrderInManage _order = new JsonOrderInManage(order);
									orderList.add(_order);
								}
							}
						}
					}
					jsonPage.setList(orderList);
					result.setPage(jsonPage);
					result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
				}
			} else {
				throw new ServiceException(jsonObject.getString("code"), jsonObject.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}

		return result;
	}

	@Override
	public PageObject<JsonOrderItemInManage> findOrderItemPage(Integer pageNo, Integer pageSize,
			Map<String, Object> searchParams, String sortParam, String sortType, Long orderId) {
		PageObject<JsonOrderItemInManage> result = new PageObject<>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("pageNo", pageNo);
			parameters.put("pageSize", pageSize);
			parameters.put("sortParam", sortParam);
			parameters.put("sortType", sortType);
			parameters.put("orderId", orderId);
			JSONObject jsonObject = apiBody(parameters, "/order/findOrderItemPage.do", "分页查询子订单", searchParams);
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(jsonObject.getString("code"))) {
				JSONObject pageJsonObject = jsonObject.getJSONObject("page");
				if (pageJsonObject != null) {
					JsonPage<JsonOrderItemInManage> jsonPage = new JsonPage<>();
					jsonPage.setPageNo(pageJsonObject.getIntValue("pageNo"));
					jsonPage.setPageSize(pageJsonObject.getIntValue("pageSize"));
					jsonPage.setTotalCount(pageJsonObject.getIntValue("totalCount"));
					List<JsonOrderItemInManage> orderItemList = new ArrayList<>();
					JSONArray jsonArray = pageJsonObject.getJSONArray("list");
					if (jsonArray != null) {
						for (int i = 0; i < jsonArray.size(); i++) {
							JSONObject _jsonObject = jsonArray.getJSONObject(i);
							if (_jsonObject != null) {
								JsonOrderItem orderItem = JSONObject.toJavaObject(_jsonObject, JsonOrderItem.class);
								if (orderItem != null) {
									JsonOrderItemInManage _orderItem = new JsonOrderItemInManage(orderItem);
									orderItemList.add(_orderItem);
								}
							}
						}
					}
					jsonPage.setList(orderItemList);
					result.setPage(jsonPage);
					result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
				}
			} else {
				throw new ServiceException(jsonObject.getString("code"), jsonObject.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}

		return result;
	}

	@Override
	public SingleObject<JsonOrder> distributeOrder(String orderNo, String expressName, String expressNo) {
		SingleObject<JsonOrder> result = new SingleObject<JsonOrder>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("orderNo", orderNo);
			parameters.put("expressName", expressName);
			parameters.put("expressNo", expressNo);

			JSONObject resultObject = api(parameters, "/order/distributeOrder.do", HttpMethod.POST, "订单发货");
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(resultObject.getString("code"))) {
				JSONObject jsonObject = resultObject.getJSONObject("object");
				if (jsonObject != null) {
					JsonOrder order = JSONObject.toJavaObject(jsonObject, JsonOrder.class);
					result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
					result.setObject(order);
				}
			} else {
				throw new ServiceException(resultObject.getString("code"), resultObject.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}
		return result;
	}

	@Override
	public SingleObject<JsonOrder> completeOrder(String orderNo) {
		SingleObject<JsonOrder> result = new SingleObject<JsonOrder>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("orderNo", orderNo);

			JSONObject resultObject = api(parameters, "/order/completeOrder.do", HttpMethod.POST, "取消订单");
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(resultObject.getString("code"))) {
				JSONObject jsonObject = resultObject.getJSONObject("object");
				if (jsonObject != null) {
					JsonOrder order = JSONObject.toJavaObject(jsonObject, JsonOrder.class);
					result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
					result.setObject(order);
				}
			} else {
				throw new ServiceException(resultObject.getString("code"), resultObject.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}
		return result;
	}

	@Override
	public PageObject<JsonPayRecord> findPayRecordPage(Integer pageNo, Integer pageSize,
			Map<String, Object> searchParams, String sortParam, String sortType, Long startTime, Long endTime) {
		PageObject<JsonPayRecord> result = new PageObject<>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("pageNo", pageNo);
			parameters.put("pageSize", pageSize);
			parameters.put("sortParam", sortParam);
			parameters.put("sortType", sortType);
			parameters.put("startTime", startTime);
			parameters.put("endTime", endTime);
			JSONObject jsonObject = apiBody(parameters, "/order/findPayRecordPage.do", "分页查询支付记录", searchParams);
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(jsonObject.getString("code"))) {
				JSONObject pageJsonObject = jsonObject.getJSONObject("page");
				if (pageJsonObject != null) {
					JsonPage<JsonPayRecord> jsonPage = new JsonPage<>();
					jsonPage.setPageNo(pageJsonObject.getIntValue("pageNo"));
					jsonPage.setPageSize(pageJsonObject.getIntValue("pageSize"));
					jsonPage.setTotalCount(pageJsonObject.getIntValue("totalCount"));
					List<JsonPayRecord> recordList = new ArrayList<>();
					JSONArray jsonArray = pageJsonObject.getJSONArray("list");
					if (jsonArray != null) {
						for (int i = 0; i < jsonArray.size(); i++) {
							JSONObject _jsonObject = jsonArray.getJSONObject(i);
							if (_jsonObject != null) {
								JsonPayRecord record = JSONObject.toJavaObject(_jsonObject, JsonPayRecord.class);
								recordList.add(record);
							}
						}
					}
					jsonPage.setList(recordList);
					result.setPage(jsonPage);
					result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
				}
			} else {
				throw new ServiceException(jsonObject.getString("code"), jsonObject.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}

		return result;
	}

	@Override
	public ListObject<JsonOrder> findOrders(Long memberId, Integer status) {
		ListObject<JsonOrder> result = new ListObject<>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("memberId", memberId);
			parameters.put("status", status);
			JSONObject resultJson = api(parameters, "/order/findOrders.do", HttpMethod.GET, "查询订单列表");
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(resultJson.getString("code"))) {
				JSONArray jsonArray = resultJson.getJSONArray("items");
				List<JsonOrder> list = new ArrayList<>();
				if (jsonArray != null) {
					for (int i = 0; i < jsonArray.size(); i++) {
						JSONObject jsonObject = jsonArray.getJSONObject(i);
						if (jsonObject != null) {
							JsonOrder order = JSONObject.toJavaObject(jsonObject, JsonOrder.class);
							list.add(order);
						}
					}
				}
				result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
				result.setItems(list);
			} else {
				throw new ServiceException(resultJson.getString("code"), resultJson.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}
		return result;
	}

	@Override
	public PageObject<JsonDistributeCall> findDistributeCallPage(Integer pageNo, Integer pageSize,
			Map<String, Object> searchParams, String sortParam, String sortType) {
		PageObject<JsonDistributeCall> result = new PageObject<>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("pageNo", pageNo);
			parameters.put("pageSize", pageSize);
			parameters.put("sortParam", sortParam);
			parameters.put("sortType", sortType);
			JSONObject jsonObject = apiBody(parameters, "/order/findDistributeCallPage.do", "分页查询订单发货提醒", searchParams);
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(jsonObject.getString("code"))) {
				JSONObject pageJsonObject = jsonObject.getJSONObject("page");
				if (pageJsonObject != null) {
					JsonPage<JsonDistributeCall> jsonPage = new JsonPage<>();
					jsonPage.setPageNo(pageJsonObject.getIntValue("pageNo"));
					jsonPage.setPageSize(pageJsonObject.getIntValue("pageSize"));
					jsonPage.setTotalCount(pageJsonObject.getIntValue("totalCount"));
					List<JsonDistributeCall> callList = new ArrayList<>();
					JSONArray jsonArray = pageJsonObject.getJSONArray("list");
					if (jsonArray != null) {
						for (int i = 0; i < jsonArray.size(); i++) {
							JSONObject _jsonObject = jsonArray.getJSONObject(i);
							if (_jsonObject != null) {
								JsonDistributeCall call = JSONObject.toJavaObject(_jsonObject,
										JsonDistributeCall.class);
								callList.add(call);
							}
						}
					}
					jsonPage.setList(callList);
					result.setPage(jsonPage);
					result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
				}
			} else {
				throw new ServiceException(jsonObject.getString("code"), jsonObject.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}

		return result;
	}

	@Override
	public SingleObject<Object> addUpdateDistributeCall(Long memberId, String orderNo) {
		SingleObject<Object> result = new SingleObject<>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("memberId", memberId);
			parameters.put("orderNo", orderNo);

			JSONObject resultJson = api(parameters, "/order/distributeCall.do", HttpMethod.POST, "订单发货提醒");
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(resultJson.getString("code"))) {
				result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
			} else {
				throw new ServiceException(resultJson.getString("code"), resultJson.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}
		return result;
	}

	@Override
	public SingleObject<Object> handleDistributeCall(String orderNo) {
		SingleObject<Object> result = new SingleObject<>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("orderNo", orderNo);

			JSONObject resultJson = api(parameters, "/order/handleDistributeCall.do", HttpMethod.POST, "处理订单发货提醒");
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(resultJson.getString("code"))) {
				result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
			} else {
				throw new ServiceException(resultJson.getString("code"), resultJson.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}
		return result;
	}

	@Override
	public ListObject<JsonOrder> findOrders(Long memberId, Integer status, Long apiClientId) {
		ListObject<JsonOrder> result = new ListObject<>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("memberId", memberId);
			parameters.put("status", status);
			parameters.put("apiClientId", apiClientId);
			JSONObject resultJson = api(parameters, "/batch/findOrders.do", HttpMethod.GET, "查询订单列表");
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(resultJson.getString("code"))) {
				JSONArray jsonArray = resultJson.getJSONArray("items");
				List<JsonOrder> list = new ArrayList<>();
				if (jsonArray != null) {
					for (int i = 0; i < jsonArray.size(); i++) {
						JSONObject jsonObject = jsonArray.getJSONObject(i);
						if (jsonObject != null) {
							JsonOrder order = JSONObject.toJavaObject(jsonObject, JsonOrder.class);
							list.add(order);
						}
					}
				}
				result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
				result.setItems(list);
			} else {
				throw new ServiceException(resultJson.getString("code"), resultJson.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}
		return result;
	}

	@Override
	public SingleObject<JsonOrder> cancelOrder(String orderNo, Long apiClientId) {
		SingleObject<JsonOrder> result = new SingleObject<JsonOrder>();
		try {
			Map<String, Object> parameters = new HashMap<>();
			parameters.put("orderNo", orderNo);
			parameters.put("apiClientId", apiClientId);

			JSONObject resultObject = api(parameters, "/batch/cancelOrder.do", HttpMethod.POST, "取消订单");
			if (StatusHouse.COMMON_STATUS_OK.getCode().equals(resultObject.getString("code"))) {
				JSONObject jsonObject = resultObject.getJSONObject("object");
				if (jsonObject != null) {
					JsonOrder order = JSONObject.toJavaObject(jsonObject, JsonOrder.class);
					result.setStatusObject(StatusHouse.COMMON_STATUS_OK);
					result.setObject(order);
				}
			} else {
				throw new ServiceException(resultObject.getString("code"), resultObject.getString("msg"));
			}
		} catch (ServiceException e) {
			result.setStatusObject(e.getStatusObject());
		} catch (Exception e) {
			e.printStackTrace();
			result.setStatusObject(StatusHouse.COMMON_STATUS_ERROR);
		}
		return result;
	}

}
